# Flags for perl for error and style checks use warnings; use strict; # Read in the name of the input file from the command line my $input = shift(@ARGV); # Open the input file for reading open(INPUT, "<", $input); # Read in the first line of the file and print it, because its a header my $header = ; print $header; # Loop through each line of the input file while () { # Remove the line return from each end of the file, don't have to do this but it helps chomp; # Split the columns of the file and save each one into a variable. We limit this to 7 columns because # we only need to work on the 6th column and we're repeating everything after that. my ($col1, $col2, $col3, $col4, $col5, $col6, $rest) = split(/\t/, $_, 7); # Split the 6th column (Swiss-Prot IDs) into an array called swiss_ids my @swiss_ids = split(/,/, $col6); # Loop through the swiss_ids array and for each swiss_id found, print the whole row foreach my $swiss_id (@swiss_ids) { print $col1 . "\t" . $col2 . "\t" . $col3 . "\t" . $col4 . "\t" . $col5 . "\t" . $swiss_id . "\t" . $rest . "\n"; } }